const query = require('./query')

const queryImageByGoodsId = async (goods_id) => {
  const sql = `select 
  goods_image_id as image_id,goods_image_path as imgUrl 
  from goods_image 
  where goods_color_id is not null and goods_id = ?
  `
  try {
    const result = await query(sql, goods_id)
    return result
  } catch (error) {
    return Promise.reject(error)
  }
}
const queryAllImageByGoodsId = async (goods_id) => {
  const sql = `select 
  goods_image_id as image_id,goods_image_path as imgUrl 
  from goods_image 
  where goods_id = ?
  `
  try {
    const result = await query(sql, goods_id)
    return result
  } catch (error) {
    return Promise.reject(error)
  }
}
module.exports = {
  queryImageByGoodsId,
  queryAllImageByGoodsId
}